/**
 * 加载页面
 * @param url
 * @param container
 * @param opt
 */
function loadURL(url,container,opt,handler){
    var containerHtml = $(container).html();
    var defaults = {
        async:true,
        topContain:$("#dashboard-content"),
        data:{}
    };

    var setting = $.extend({},defaults,opt);

    $.ajax({
        type: "POST",
        url: url,
        dataType: "html",
        contentType: "application/x-www-form-urlencoded; charset=utf-8",
        cache:false,
        data:setting.data,
        async: setting.async,
        beforeSend:function () {
            container.html('<h1><i class="fa fa-cog fa-spin"></i> 加载中...</h1>');
            if (container[0] == setting.topContain[0]) {
                // scroll up
                $("html, body").animate({
                    scrollTop : 0
                }, "fast");
            } else {
                container.animate({
                    scrollTop : 0
                }, "fast");
            }
            
        },
        success:function (data) {
            if(data.state && data.state=="400"){
                container.css({
                    opacity : "0.0"
                }).html(containerHtml).delay(50).animate({
                    opacity : "1.0"
                }, 300);
            }else{
                container.css({
                    opacity : "0.0"
                }).html(data).delay(50).animate({
                    opacity : "1.0"
                }, 300);
            }
            
            if(typeof handler === "function"){
                handler(data);
            }
        },
        // error

    })

}